package com.example.demo.thread;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ThreadPoolDemo {
    public static void main(String[] args) {
        ExecutorService pool = Executors.newFixedThreadPool(5);
        ThreadPool tp = new ThreadPool();

        for (int i = 0; i < 10; i++) {
            pool.submit((Runnable) tp);
        }

        pool.shutdown();

    }
}

class ThreadPool implements Runnable {
    private int i = 0;

    public void run() {
        while (i <= 100) {
            System.out.println(Thread.currentThread().getName() + ":" + i++);
        }
    }
}
